package com.zb.lister;

import com.alibaba.fastjson.JSON;
import com.zb.config.RabbitConfig;
import com.zb.entity.Exchangescore;
import com.zb.service.ExchangescoreService;
import com.zb.service.ScoreService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ListerScore {

    @Autowired
    private ScoreService scoreService;

    @RabbitListener(queues = RabbitConfig.SCORE_TWO_QUEUE)
    public void updateUserScore(String msg) throws Exception{
        Exchangescore exchangescore = JSON.parseObject(msg, Exchangescore.class);
        Integer flag = scoreService.qdtxModifyScore(exchangescore.getExchangedCredit(), exchangescore.getUserId());
        if (flag>0) {
            System.out.println("修改用户积分成功！");
        }else{
            System.out.println("不成功！");
        }
    }

}
